package web.servlet.request;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author Administrator
 * @Date 2020/5/14 16:17
 **/
@WebServlet("/requestDome2")
public class RequestDome2 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        /*防盗链*/
        String referer = req.getHeader("referer");
        System.out.println(referer);
        if(referer!=null){
            if(referer.contains("/web")){
                System.out.println("可以访问");
            }else {
                System.out.println("没有权限");
            }
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
